<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="<{$ipath}>wx/style/media.css" media="all" />
<script type="text/javascript"  src="<{$ipath}>public/js/head.js"></script>
<script type="text/javascript"  src="<{$ipath}>wx/js/jquery.min.js"></script>
<script>
$(function(){
	$("#isall").toggle(function(){
		$("#delimglist").attr("class","wxbutton_normal");
		$("#delimglist").attr("onclick","delimg()");
	},function(){
		$("#delimglist").attr("class","wxbutton_normal");
		$("#delimglist").removeAttr("onclick","delimg()");
	});
	$(".voicetit").children(".wxbutton").click(function(){
		$("#shade").show();
		$("#addvoice").show();
	})
	$(".videotit").children(".wxbutton").click(function(){
		$("#shade").show();
		$("#addvideo").show();
	})
	var path = 0;
	$(".voicecon_info img").click(function(){
		var au = $('#audio'),
			_this = $(this);
		if (path != _this.attr('asrc'))
		{
			path = _this.attr('asrc');
			au.attr('src',path).get(0).play();
			$(".voicecon_info img").attr("src","<{$ipath}>wx/images/voice_stop.png");
			_this.attr("src","<{$ipath}>wx/images/voice_play.gif");
		}else{
			if(au.get(0).paused){
				au.get(0).play();
				_this.attr("src","<{$ipath}>wx/images/voice_play.gif");
			}else{
				au.get(0).pause();
				_this.attr("src","<{$ipath}>wx/images/voice_stop.png");
			}
		}
	})

	/*$(".voicecon_info img").click(function(){
		if($(this).next("audio").get(0).paused){
			$(this).next("audio").get(0).play();
			$(this).attr("src","<{$ipath}>wx/images/voice_play.gif");
		}else{
			$(this).next("audio").get(0).pause();
			$(this).attr("src","<{$ipath}>wx/images/voice_stop.png");
		}
	})*/
});
function closehidd(){
	$(".hidddiv").hide();
	$("#shade").hide();
}
function hiddupload(){
	$("#hiddupload").submit();
}
function delmedia(id){
	if(confirm('素材删除后无法找回，确认删除该素材么?')){
		var url = '?g=wx&m=weixin&a=delmedia&id='+id;
		$.get(url,function(data){
			alert(data.msg);
			if(data.error==1000 || data.error=='1000'){
				$(".item_"+id).remove();
			}
			return false;
		},'json');
	}else{
		return false;
	}
}
</script>
<style>.topnav{ width:94%;margin:0 auto;padding-top:16px;font-size:14px;line-height:18px;}.topnav *{color:#333;}</style>
</head>

<body>
<div class="topnav"><a class="level-1" href="?g=index&m=index&a=platform">我的服务</a>><a class="level-2" href="?g=index&m=index&a=wxpla">微信公众号</a>><span class="level-3">回复设置</span></div>
<div class="wxmedia">
    <h1>素材管理</h1>
    <ul class="nav"><li <{if $type=='news' || empty($type)}>class="select"<{/if}>><a href="?g=wx&m=weixin&a=wxmedia&type=news">图文</a></li><li <{if $type=='image'}>class="select"<{/if}>><a href="?g=wx&m=weixin&a=wxmedia&type=image">图片</a></li><li <{if $type=='voice'}>class="select"<{/if}>><a href="?g=wx&m=weixin&a=wxmedia&type=voice">语音</a></li><li <{if $type=='video'}>class="select"<{/if}>><a href="?g=wx&m=weixin&a=wxmedia&type=video">视频</a></li></ul> 
<{if $type=='image'}>
  <div class="imglist">
    	<ul class="imgtit"><!--<input type="checkbox" id="isall" value="1" />全选 <input type="button" id="delimglist" value="删除选中" class="wxbutton_cancel" />--><em><form action="?g=wx&m=weixin&a=mediaupload" target="hiddfrm" method="post" enctype="multipart/form-data" id="hiddupload"><input type="file" name="image" class="hiddfile" onChange="hiddupload()" /><input type="hidden" name="type" value="image" /><input type="button" value="本地上传" class="wxbutton" /> <input type="button" value="同步图片素材" class="wxbutton_cancel" onClick="alert('功能暂未开通')" /></form></em></ul>
        <{if !empty($list)}>
        <ul class="imgcon">
        <{section name=l loop=$list}>
        	<li class="item_<{$list[l].id}>">
                <dd><img src="<{$list[l].url}>" width="169" height="169" /></dd>
                <dd class="imgcon_info"><{$list[l].title}></dd>
                <dd class="imgcon_edit"><a href="<{$list[l].url}>" target="_blank"><i class="icon_show"></i></a></a><em><a onClick="delimg()"><i class="icon_del" onClick="delmedia(<{$list[l].id}>)"></i></a></em></dd>
            </li>
        <{/section}>
    	</ul>
        <{else}>
        <div class="nolist">还没有相关内容，请上传或同步素材</div>
        <{/if}>
   </div>
<{elseif $type=='voice'}>
   <div class="voicelist">
   	<ul class="voicetit"><input type="button" class="wxbutton" value="+新建语音" />  <input type="button" value="同步语音素材" class="wxbutton_cancel" onClick="alert('功能暂未开通')" /></ul>
    <{if !empty($list)}>
    <ul class="voicecon">
    <{section name=l loop=$list}>
    	<div class="item_<{$list[l].id}>">
		<ul class="voicecon_info">
		<li><img src="<{$ipath}>wx/images/voice_stop.png" width="60px" asrc="<{$list[l].url}>" /></li>
		<li>
			<dd><{$list[l].title}><em><{$list[l].size}></em></dd>
			<dd>创建于：<{$list[l].tim}></dd>
		</li>
		</ul>
            <ul class="voicecon_edit"><a href="<{$list[l].url}>" target="_blank"><i class="icon_download"></i></a><em onClick="delmedia(<{$list[l].id}>)"><i class="icon_del"></i></em></ul>
        </div>
    <{/section}>
    </ul>
	<audio id="audio" src=""></audio>	

    <{else}>
    <div class="nolist">还没有相关内容，请上传或同步素材</div>
    <{/if}>
   </div>
<{elseif $type=='video'}>
   <div class="videolist">
   	<ul class="videotit"><input type="button" class="wxbutton" value="+新建视频" />  <input type="button" value="同步视频素材" class="wxbutton_cancel" onClick="alert('功能暂未开通')" /></ul>
    <{if !empty($list)}>
    <ul class="videocon">
    <{section name=l loop=$list}>
    	<li class="item_<{$list[l].id}>">
        	<ul class="videocon_info">
            	<li class="tit"><{$list[l].title}><br><{$list[l].tim}></li>
                <li class="video"><video controls src="<{$list[l].url}>" width="280"></video></li>
                <li class="desc"><{$list[l].content}></li>
            </ul>
            <ul class="videocon_edit"><a href="<{$list[l].url}>" target="_blank"><i class="icon_download"></i></a><em onClick="delmedia(<{$list[l].id}>)"><i class="icon_del"></i></em></ul>
        </li>
    <{/section}>
    </ul>
    <{else}>
    <div class="nolist">还没有相关内容，请上传或同步素材</div>
    <{/if}>
   </div>
<{else}>
	<div class="newslist">
    	<ul class="newstit"><a href="?g=wx&m=weixin&a=wxnews" target="_blank"><input type="button" class="wxbutton" value="+新建图文消息" /></a>  <input type="button" value="同步图文素材" class="wxbutton_cancel" onClick="alert('功能暂未开通')" /></ul>
        <{if !empty($list)}>
        <ul class="newscon">
        <{section name=l loop=$list}>
        	<div class="item_<{$list[l].id}>">
           	  <ul class="newsfrist">
                	<li><{$list[l].tim}></li>
                    <li><img src="<{$list[l].first.url}>" width="100%"></li>
                    <li class="tips"><{$list[l].first.title}></li>
                </ul>
                <{foreach item=v from=$list[l].more}>
                <ul class="news">
               	  <li><{$v.title}></li><em><img src="<{$v.url}>" style="max-width:80px;" /></em>
                </ul>
                <{/foreach}>
                <ul class="news_edit"><a href="?g=wx&m=weixin&a=wxnews&id=<{$list[l].id}>" target="_blank"><i class="icon_edit"></i></a><em onClick="delmedia(<{$list[l].id}>)"><i class="icon_del"></i></em></ul>
            </div>
	<{/section}>
        </ul>
        <{else}>
    <div class="nolist">还没有相关内容，请上传或同步素材</div>
    <{/if}>
    </div>
<{/if}>
</div>
<div id="shade"></div>
<div id="addvoice" class="hidddiv">
<form action="?g=wx&m=weixin&a=mediaupload" method="post" enctype="multipart/form-data" target="hiddfrm" onSubmit="return checkfrm('voice')">
	<h3>新建语音<em onClick="closehidd()"><i class="icon_close"></i></em></h3>
    <ul>
    	<li>语音标题：<input type="text" name="title" id="vtitle" class="wxput" value="" /></li>
        <li>本地上传：<input type="file" name="voice" /></li>
    </ul>
    <h4><input type="hidden" name="type" value="voice" /><input type="submit" class="wxbutton" value="添加"> <input type="button" class="wxbutton_cancel" onClick="closehidd()" value="取消" /></h4>
</form>
</div>
<div id="addvideo" class="hidddiv">
<form action="?g=wx&m=weixin&a=mediaupload" method="post" enctype="multipart/form-data" target="hiddfrm" onSubmit="return checkfrm('video')">
<h3>新建视频<em onClick="closehidd()"><i class="icon_close"></i></em></h3>
    <ul>
    	<li>视频标题：<input type="text" name="title" id="dtitle" class="wxput" value="" /></li>
        <li>本地上传：<input type="file" name="video"  /></li>
        <li>视频简介：<textarea name="desc" id="desc" class="wxtextarea"></textarea></li>
    </ul>
    <h4><input type="hidden" name="type" value="video" /><input type="submit" class="wxbutton" value="添加"> <input type="button" onClick="closehidd()" class="wxbutton_cancel" value="取消" /></h4>
</form>
</div>
<div class="loading"><img src="<{$ipath}>wx/images/loading.gif" /></div>
<script>
function checkfrm(type){
	if(type=='voice'){
		if($("#vtitle").val()=='' || $("#vtitle").val()==null){
			alert('请填写语音标题');
			return false;
		}else{
			$('.loading').css({'display':'-webkit-box'});
		}
	}else if(type=='video'){
		if($("#dtitle").val()=='' || $("#dtitle").val()==null){
			alert('请填写视频标题');
			return false;
		}else if($("#desc").val()=='' || $("#desc").val()==null){
			alert('请填写视频简介');
			return false;
		}else{
			$('.loading').css({'display':'-webkit-box'});
		}
	}else{
		return false;
	}
	return;
}
function loadhide(str){
	$('.loading').hide();
	alert(str);
}
</script>
<iframe width="0" height="0" name="hiddfrm" id="hiddfrm" scrolling="no" frameborder="0" style="display:none"></iframe>
</body>
</html>
